package com.shuyun.xxx.guava.practice;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by feng.ding on 2017/2/8.
 */
public class SectionA {
    private static final ImmutableSet<String> COLOR_NAMES = ImmutableSet.of(
            "yellow",
            "red",
            "blue",
            "green",
            "orange",
            "black"
    );
    public static void main(String[] args) {
        String s = "12341235123123";
        countWord(s);


    }
    public static void countWord(String s){
        Map<Character, Integer> map = new HashMap<>();
        for(int i = 0; i < s.length(); i++){
            Integer count = map.get(s.charAt(i));
            if(count == null){
                map.put(s.charAt(i), 1);
            }else{
                map.put(s.charAt(i), count + 1);
            }
        }
        for(Map.Entry<Character, Integer> entry : map.entrySet()){
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }
}